layout(location=0) in vec3 in_pos;
layout(location=1) in vec3 in_normal;
layout(location=2) in vec4 in_tangent;
layout(location=3) in vec4 in_color;
layout(location=4) in vec2 in_uv;

out vec4 out_color;
out vec3 world_pos;
out vec2 out_uv;
out float3x3 out_tangent_world_mtx;

void main()
{
	float4 world_pos4=world_mtx*vec4(in_pos,1);
	world_pos=world_pos4.xyz;
	float4 p=viewproj_mtx*world_pos4;
//	p.z=(p.z+1)*0.5;
	
	gl_Position=p;
	out_uv=in_uv;
	out_color=in_color;
	
	float3x3 tangent_local_mtx = float3x3( in_tangent.xyz, cross( in_normal, in_tangent.xyz) * in_tangent.w, in_normal.xyz );
//	float3x3 world3=float3x3(world_mtx[0].xyz,world_mtx[1].xyz,world_mtx[2].xyz);
//	float3x3 TangentToWorld = world3*tangent_local_mtx;
	out_tangent_world_mtx = (float3x3(world_mtx))*tangent_local_mtx;
}